package com.epfly.promo.activity.impl.discount.predicate;


import com.epfly.promo.activity.entity.ActivityEntity;
import com.epfly.promo.activity.impl.discount.ActivityWrapper;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;



/**
 * 活动时间过滤器
 */
@Order(value = PredicateOrder.ACTIVITY_TIME_ORDER)
@Service
public class ActivityTimePredicate implements ActivityDiscountPredicate {


    @Override
    public boolean test(ActivityWrapper activityWrapper) {
        Long orderTime = activityWrapper.getOrderTime();
        ActivityEntity activityEntity = activityWrapper.getActivityEntity();
        // 订单时间大于等于活动开始时间并且小于等于活动结束时间
        if (orderTime <= activityEntity.getActivityEndTime() && orderTime >= activityEntity.getActivityStartTime()) {
            return true;
        }
        return false;
    }

}
